//
//  TGNetworkManager.h
//  指乎
//
//  Created by Dean on 16/6/13.
//  Copyright © 2016年 Dean. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#import "TGResponseItem.h"

typedef  void(^LZTResponseSuccess) (TGResponseItem *responseItem);
typedef  void(^LZTResponseFailure) (NSError *error);

@interface TGNetworkManager : AFHTTPSessionManager
+ (instancetype)sharedClient;
//+ (void)setNotShowTip;
+ (BOOL)getProxyStatus;
+ (NSString *)addCommontURLPrefix:(NSString*)oldUrl;
+ (NSDictionary *)parametserToJson:(NSDictionary *)dict;

/**
 *  发送get请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
+ (NSURLSessionDataTask *)GETWithURLString:(NSString *)URLString
                                parameters:(id)parameters
                                   success:(LZTResponseSuccess)success
                                   failure:(LZTResponseFailure)failure;

+ (NSURLSessionDataTask *)GETWithURLString:(NSString *)URLString
                                    header:(NSDictionary <NSString *, NSString *>*)header
                                 parameters:(NSDictionary *)parameters
                                    success:(LZTResponseSuccess)success
                                    failure:(LZTResponseFailure)failure;

/*!
 *  POST请求接口，若不指定baseurl，可传完整的url
 *
 *  @param url     接口路径，如/path/getArticleList
 *  @param parameters  接口中所需的参数，如@{"categoryid" : @(12)}
 *  @param success 接口成功请求到数据的回调
 *  @param failure    接口请求数据失败的回调
 *
 *  @return 返回的对象中有可取消请求的API
 */
+ (NSURLSessionDataTask *)POSTWithURLString:(NSString *)url
                                 parameters:(NSDictionary *)parameters
                                    success:(LZTResponseSuccess)success
                                    failure:(LZTResponseFailure)failure;
+ (NSURLSessionDataTask *)POSTWithURLString:(NSString *)url
                                    header:(NSDictionary <NSString *, NSString *>*)header
                                 parameters:(NSDictionary *)parameters
                                    success:(LZTResponseSuccess)success
                                    failure:(LZTResponseFailure)failure;

/*!
 *  Delete请求接口，若不指定baseurl，可传完整的url
 *
 *  @param url     接口路径，如/path/getArticleList
 *  @param parameters  接口中所需的参数，如@{"categoryid" : @(12)}
 *  @param success 接口成功请求到数据的回调
 *  @param failure    接口请求数据失败的回调
 *
 *  @return 返回的对象中有可取消请求的API
 */
+ (NSURLSessionDataTask *)DELETEWithURLString:(NSString *)url
                                 parameters:(NSDictionary *)parameters
                                    success:(LZTResponseSuccess)success
                                    failure:(LZTResponseFailure)failure;

/*!
 *  PUT请求接口，若不指定baseurl，可传完整的url
 *
 *  @param url     接口路径，如/path/getArticleList
 *  @param parameters  接口中所需的参数，如@{"categoryid" : @(12)}
 *  @param success 接口成功请求到数据的回调
 *  @param failure    接口请求数据失败的回调
 *
 *  @return 返回的对象中有可取消请求的API
 */
+ (NSURLSessionDataTask *)PUTWithURLString:(NSString *)url
                                   parameters:(id)parameters
                                      success:(LZTResponseSuccess)success
                                      failure:(LZTResponseFailure)failure;
/**
 *
 *	取消所有请求
 */
+ (void)cancelAllRequest;
/**
 *
 *	取消某个请求。如果是要取消某个请求，最好是引用接口所返回来的NSURLSessionDataTask对象，
 *  然后调用对象的cancel方法。如果不想引用对象，这里额外提供了一种方法来实现取消某个请求
 *
 *	@param url				URL，可以是绝对URL，也可以是path（也就是不包括baseurl）
 */
+ (void)cancelRequestWithURL:(NSString *)url;


+ (void)startRequestWithURL:(NSString *)url
                     method:(NSString *)method
                  paramters:(NSDictionary *)paramters
                    success:(LZTResponseSuccess)success
                    failure:(LZTResponseFailure)failure;

//上传图片
+ (void)uploadImage:(UIImage *)image filePath:(NSString *)filePath  success:(LZTResponseSuccess)success failure:(LZTResponseFailure)failure;

//上传视频
+ (void)uploadVideo:(NSString *)localPath filePath:(NSString *)filePath success:(LZTResponseSuccess)success failure:(LZTResponseFailure)failure;

//识别身份证 0 或 营业执照 1
+ (void)recorginzedWithType:(NSInteger)type image:(UIImage *)image filePath:(NSString *)filePath success:(LZTResponseSuccess)success failure:(LZTResponseFailure)failure;

//文件上传
+ (void)uploadFileWithFileUrl:(NSURL *)fileUrl
                     filePath:(NSString *)filePath
                      success:(LZTResponseSuccess)success
                      failure:(LZTResponseFailure)failure;


+ (void)uploadFileWithFileData:(NSData *)fileData fileName:(NSString *)fileName filePath:(NSString *)filePath  mimeType:(NSString *)mimeType success:(LZTResponseSuccess)success failure:(LZTResponseFailure)failure;



@end
